package com.wltt.product.frfront.service;

import com.wltt.product.frfront.mapper.WaitModeMapper;
import com.wltt.product.frfront.model.ResultData;
import com.wltt.product.frfront.model.po.WaitModePO;
import com.wltt.product.frfront.model.vo.AllSwingTypeRSP;
import com.wltt.product.frfront.model.vo.AllWaitModeRSP;
import com.wltt.product.frfront.service.base.BaseServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;


/**
 * @ClassName: WaitModeServiceImpl
 * @Description: 等待模式 逻辑服务类<br/>
 * 不做业务校验，参数校验统一放到前置的Service中
 * @Date: 2025-07-03 18:01:51
 * @Author yanggl
 */
@Service(value = "waitModeService")
public class WaitModeServiceImpl extends BaseServiceImpl<WaitModePO, Long> implements WaitModeService {

    private WaitModeMapper waitModeMapper;

    //构造方法
    public WaitModeServiceImpl(WaitModeMapper waitModeMapper) {
        super(waitModeMapper);
        this.waitModeMapper = waitModeMapper;
    }

    /**
     * 查询所有等待模式
     *
     * @return
     */
    @Override
    public ResultData allWaitMode() {
        List<WaitModePO> waitModePOList = waitModeMapper.queryALL();
        List<AllWaitModeRSP> rsps = Optional.ofNullable(waitModePOList).orElse(new ArrayList<>())
                .stream().map(po -> {
                    AllWaitModeRSP rsp = new AllWaitModeRSP();
                    BeanUtils.copyProperties(po, rsp);
                    rsp.setWaitModeId(po.getId());
                    return rsp;
                }).collect(Collectors.toList());
        return ResultData.success(rsps);
    }
}